package cn.com.cifi.mars.web.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@Slf4j
public class XssFilter implements Filter {
 
    @Override
    public void init(FilterConfig config) {
        log.debug("Xss Filter is working -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ======================= safe! =====================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
        log.debug("                      -> ===================================================!");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        XssHttpServletRequestWrapper xssHttpServletRequestWrapper = new XssHttpServletRequestWrapper((HttpServletRequest)request);
        chain.doFilter(xssHttpServletRequestWrapper, response);
    }

    @Override
    public void destroy() {}
}